
try:
    from PyQt5.QtGui import *
    from PyQt5.QtCore import *
    from PyQt5.QtWidgets import *
except ImportError:
    from PyQt4.QtGui import *
    from PyQt4.QtCore import *

from lxml import etree,objectify
from dir_content import dir_content

import numpy as np
import os,sys
import json
import threading 


class main_gui(QWidget):
    def __init__(self):
        super().__init__()


        self.content_frame = QFrame(self)
        self.content_frame.setFrameShape(QFrame.StyledPanel)
        self.editer_frame = QFrame(self)
        self.editer_frame.setStyleSheet('background-color:black;')

        self.content_vlay = QVBoxLayout(self)
        self.content_vlay.addWidget(self.editer_frame)
        self.content_vlay.setContentsMargins(0, 0, 0, 0)
        self.content_frame.setLayout(self.content_vlay)

        remote_cframe = QFrame(self)
        host_frame = QFrame(self)
        cmd_frame = QFrame(self)
        cmd_vlay = QVBoxLayout()
        cmd_vlay.addWidget(host_frame)
        cmd_vlay.addWidget(cmd_frame)
        remote_cframe.setLayout(cmd_vlay)
        remote_cframe.setStyleSheet('background-color:black;')

        splitter1 = QSplitter(Qt.Vertical)
        splitter1.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding);
        splitter1.setContentsMargins(0, 0, 0, 0)
        splitter1.addWidget(self.content_frame)
        splitter1.addWidget(remote_cframe)
        splitter1.setStyleSheet("QSplitter::handle { background-color: yellow }");
        splitter1.setHandleWidth(2); 
        splitter1.setStretchFactor(0, 20)
        splitter1.setStretchFactor(1, 1)

        splitter2 = QSplitter(Qt.Horizontal)
        splitter2.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding);
        splitter2.setStyleSheet("QSplitter::handle { background-color: blue }");
        splitter2.setHandleWidth(0); 
        self.menu_frame = dir_content('.')
        # self.menu_frame.setFrameShape(QFrame.StyledPanel)
        splitter2.addWidget(self.menu_frame)
        splitter2.addWidget(splitter1)
        splitter2.setStretchFactor(1, 3)
        splitter2.setStretchFactor(2, 7)
        splitter2.setContentsMargins(0, 0, 0, 0)

        bbox = QHBoxLayout(self)
        bbox.setContentsMargins(0, 0, 0, 0)
        bbox.addWidget(splitter2)
        cbox_area = QFrame(self)
        cbox_area.setLayout(bbox)
        cbox_area.setStyleSheet('background-color:white;')

        toolbox = QLabel('a')
        toolbox.setFixedSize(10, 10)
        toolbox.setStyleSheet('background-color:red;')
        toolbox.setMargin(0)

        htools_hlay = QHBoxLayout(self)
        htools_hlay.addWidget(toolbox)
        htools_hlay.addStretch()
        htools_hlay.setContentsMargins(10, 0, 0, 10)
        htools_hlay.setSpacing(2)
        
        htools_area = QFrame(self)
        htools_area.setFixedHeight(10)
        htools_area.setStyleSheet('background-color:green;')
        htools_area.setLayout(htools_hlay)
        
        # htools_area.setFixedWidth(30)
        fstatus_area = QFrame(self)
        fstatus_hlay = QHBoxLayout(self)
        fstatus_hlay.setContentsMargins(10, 0, 5, 0)
        fstatus_hlay.addWidget(QLabel('aaaa'))
        fstatus_hlay.addStretch()
        fstatus_hlay.setSpacing(2)
        fstatus_area.setLayout(fstatus_hlay)
        fstatus_area.setFixedHeight(10)
        fstatus_area.setStyleSheet('background-color:blue;')
        # htools_area.setFixedWidth(30)


        win_vlay = QVBoxLayout()
        win_vlay.addWidget(htools_area)
        win_vlay.addWidget(cbox_area)
        win_vlay.addWidget(fstatus_area)
        win_vlay.setContentsMargins(0, 0, 0, 0)
        win_vlay.setSpacing(2)
        self.setStyleSheet('background-color:yellow;')


        self.setLayout(win_vlay)
        self.setGeometry(0, 0, 600, 480)
        self.setWindowTitle('SSH GUI')
        self.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = main_gui()
    sys.exit(app.exec_())